<%@ page import="org.springframework.util.ClassUtils" %>

<%@ page import="com.opeace.Program" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'program.label', default: 'Program')}" />
		<title><g:message code="default.show.label" args="[entityName]" /></title>
	</head>
	<body>
		<a href="#show-program" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		
        <h1>${programInstance.name}</h1>
		<table align="center" width="100%">
                  <tr>

		<td align="left" width="50%" style="vertical-align: top;">
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<ol class="property-list program">
			
                                <g:if test="${programInstance?.name}">
				<li class="fieldcontain">
					<span id="name-label" class="property-label"><g:message code="program.name.label" default="Name" /></span>
					
						<span class="property-value" aria-labelledby="name-label"><g:fieldValue bean="${programInstance}" field="name"/></span>
					
				</li>
				</g:if>
                            
				<g:if test="${programInstance?.description}">
				<li class="fieldcontain">
					<span id="description-label" class="property-label"><g:message code="program.description.label" default="Description" /></span>
					
						<span class="property-value" aria-labelledby="description-label"><g:fieldValue bean="${programInstance}" field="description"/></span>
					
				</li>
				</g:if>
                          
                                <g:if test="${programInstance?.persons}">
				<li class="fieldcontain">
					<span id="persons-label" class="property-label"><g:message code="program.persons.label" default="Persons" /></span>
					
						<g:each in="${programInstance.persons}" var="p">
                                                <g:set var="link" value="${createLink(controller: ClassUtils.getShortName(p?.person?.getClass())[0].toLowerCase() + ClassUtils.getShortName(p?.person?.getClass())[1..-1], action: 'show', id: p?.person.id)}" />
						<span class="property-value" aria-labelledby="persons-label"><g:link controller="personProgram" action="show" id="${p.id}">${p?.person.firstName.encodeAsHTML()} ${p?.person.lastName.encodeAsHTML()}</g:link></span>
						</g:each>
					
				</li>
				</g:if>
			
				<g:if test="${programInstance?.endDate}">
				<li class="fieldcontain">
					<span id="endDate-label" class="property-label"><g:message code="program.endDate.label" default="End Date" /></span>
					
						<span class="property-value" aria-labelledby="endDate-label"><g:formatDate date="${programInstance?.endDate}" /></span>
					
				</li>
				</g:if>
			
				<g:if test="${programInstance?.startDate}">
				<li class="fieldcontain">
					<span id="startDate-label" class="property-label"><g:message code="program.startDate.label" default="Start Date" /></span>
					
						<span class="property-value" aria-labelledby="startDate-label"><g:formatDate date="${programInstance?.startDate}" /></span>
					
				</li>
				</g:if>
			</ol>
			<g:form>
				<fieldset class="buttons">
					<g:hiddenField name="id" value="${programInstance?.id}" />
					<g:link class="edit" style="font-size: 18px;" action="edit" id="${programInstance?.id}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
					<g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
				</fieldset>
			</g:form>
<div class="fieldcontain ${hasErrors(bean: personProgramInstance, field: 'persons', 'error')} ">
                 
<ul class="one-to-many">
<li class="add">
<g:message code="program.persons.label" default="Persons" />&nbsp
<g:link controller="personProgram" action="create" params="['program.id': programInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'personProgram.label', default: 'Person')])}</g:link>
</li>
</ul>
</div>
		 </td>
                  </tr>

	</table>
         <div class="nav" role="navigation">
			<ul>
				<li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
			</ul>
                      </div>
		
	</body>
</html>
